﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LicenserProduction
{
    public partial class FeatureDetails : UserControl
    {
        public FeatureDetails()
        {
            InitializeComponent();
        }

        public void Init(LicenserInformation licInfo, int licenceId)
        {
            licenserInformation = licInfo;
            featuresBindingSource.DataSource = licInfo;
            featuresBindingSource.DataMember = "Features";
            featuresBindingSource.Filter = "LicenseId = " + licenceId;
            m_licenseId = licenceId;

            featuresBindingSource.ListChanged += new ListChangedEventHandler(featuresBindingSource_ListChanged);
        }

        void featuresBindingSource_ListChanged(object sender, ListChangedEventArgs e)
        {
            if (e.ListChangedType == ListChangedType.ItemAdded)
            {
                ((DataRowView)featuresBindingSource[e.NewIndex]).Row["LicenseId"] = m_licenseId;
            }
        }

        public BindingSource Features
        {
            get
            {
                return featuresBindingSource;
            }
        }

        int m_licenseId;
    }
}
